package com.kaifamiao.www.demo.do0908;

import java.sql.*;

public class DButil {
    public static void main(String[] args) {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            String url = "jdbc:mysql://localhost:3306/kfm";
            String user = "root";
            String password = "";
            Connection conn = DriverManager.getConnection(url,user,password);
            String sql  = "update emp set ename = ? where empno = ?";
            PreparedStatement preparedStatement = conn.prepareStatement(sql);
            preparedStatement.setObject(1,"bbb");
            preparedStatement.setObject(2,12);
            int rows = preparedStatement.executeUpdate();
            System.out.println(rows);
            preparedStatement.close();
            conn.close();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }


}
